
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>教师页面</title>
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
	</head>
	<style>
		  .table_2{
          	height: 38px;
          	background-image:url(img/广科logo_3.jpg);
          	background-size: auto;
          	width: 1175px;
          }
             .td_1{
          	text-align: right;
          	width:650px;}
          	  .div_3{
         	  border: 2px solid #7FFFD4;
         	height: 330px;
         	width: 1173px;
         }
		
	</style>
	<body>
		    <head>    
		     <div class="div_1 "> 		 	
           	<div class="div_2">
           	  <table class="table_2">
           		<tr class="tr_1">
           			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
           		    <td><a href="TeacherShow.html">查看所有课程</a>&nbsp;</td>
					<td class="td_1"> 欢迎你 &nbsp;&nbsp;
						<button class="a_1" id="logout">退出登录</button>
					</td>
           		</tr>
           	  </table>
           	</div>
           	<hr color="lightskyblue" />
           	    	<img src="img/广科logo.JPG" height="80px" width="100%" align="center"/>
             <hr color="lightskyblue" />         
          </div>  
        	</head>
		
		        
         <div class="div_3">
			 <h1>新增课程</h1>
			 <div>
				 <div>课程名称：<input id="course_name" /></div>
				 <div>课程学分：<input id="point" /></div>
				 <div>开始时间：<input id="timeon" /></div>
				 <div>结束时间：<input id="timeend" /></div>
				 <div>上课地点：<input id="location" /></div>
				 <div>限制人数：<input id="limited" /></div>
			 </div>
			 <button id="submit">添加课程</button>
         </div> 	
          	
	
	   <table class="table_3"> 
            <hr size="3" color="lightskyblue"/>
            <img src="img/尾巴.jpg" align="center" width="100%"> 
           </table> 
           
           	</div>
		<script>
			$("#logout").click(
					function () {
						$.ajax({
							type:"POST",
							url:"logout",
							contentType: "application/json; charset=utf-8",
							data:{},
							success:function(data){
								console.log(data)
								alert(data.msg)
								window.location.href="index.html"
							},
							error:function(jqXHR){
								console.log("Error: "+jqXHR.status);
							}
						});
					}
			)
			$('#submit').click(
					function () {
						var course_name = $('#course_name').val();
						var point = $('#point').val();
						var timeon = $('#timeon').val();
						var timeend = $('#timeend').val();
						var location = $('#location').val();
						var limited = $('#limited').val();

						$.ajax({
							type:"POST",
							url:"AddCourseServlet",
							contentType: "application/json; charset=utf-8",
							data:JSON.stringify({course_name:course_name,point:point,timeon:timeon,timeend:timeend,location:location,limited,limited}),
							success:function(data){
								console.log(data)
								alert(data.msg)
							},
							error:function(jqXHR){
								console.log("Error: "+jqXHR.status);
							}
						});
					}
			)
		</script>
	</body>
</html>
